package com.nbatch.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
public class BookController {
    @GetMapping("/books")
    public Book books() {
        List<Book> books = new ArrayList<>();
        Book b1 = new Book();
        b1.setName("三国演义");
        b1.setAuthor("罗贯中");
        b1.setPrice(30f);
        b1.setPublicationDate(new Date());

        /*
        * 最终将直接返回json串数据
        * {"name":"三国演义","author":"罗贯中","publicationDate":"2021-04-04"}
        *
        *
        * 对于 fastJson 的返回如下：
        *
        * { "@type":"com.nbatch.controller.Book", "author":"罗贯中", "name":"三国演义", "price":30.0F, "publicationDate":"2021-04-04" }
        * */
        return b1;



    }

}
